home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / r / rexx_plus_compiler / rexxpluscompiler2.dms / in.adf / Examples / rexxcompall.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1991-08-28  |  3.8 KB  |  207 lines

  1. /* RexxCompAll.rexx:                        */
  2. /*     rexx program to frontend to the REXX PLUS Compiler.    */
  3. /*    it takes parameters from the command line, builds a file */
  4. /*    list, compiles and links each program in the list.    */
  5. /*                                */
  6. /*    rx RexxCompAll filname [compiler-options] [\parameters]    */
  7.  
  8. /*    filename:                        */
  9. /*        directory/path/name                */
  10. /*        *    as the name causes all programs in    */
  11. /*             the directory to be compiled.        */
  12.  
  13. /*     compiler-options:                    */
  14. /*        any valid rexxplus compiler option        */
  15.  
  16. /*    parameters:                        */
  17. /*        >    causes the errormessage to be saved.    */
  18. /*        NOEXIST    causes only programs that are not in     */
  19. /*            RPDIR: directory to be compiled.    */
  20. /*        DELOBJ    causes the object file to be deleted     */
  21. /*            afeter the link.            */
  22. /*        NOLINK    causes the linker to bypassed.        */
  23. /*        NOCOMP    causes the compiler to be bypassed.    */
  24.  
  25. signal on break_c
  26. signal on syntax
  27. signal on error
  28. signal on failure
  29. signal on ioerr
  30.  
  31. address command
  32. parse upper arg optn'\'dboptn
  33.  
  34. tstobj = ''
  35.  
  36. errors = work'err'pragma('i')
  37. if ~open('errors',errors,'w') then exit 10
  38. call close('errors')
  39.  
  40. if ~show('L',"rexxsupport.library") then
  41.    call addlib "rexxsupport.library",0,-30
  42.    
  43. if ~show('L',"rexxmathlib.library") then
  44.    call addlib "rexxmathlib.library",0,-30
  45.  
  46. if pos('>',dboptn) ~= 0
  47. then redirect = '>ram:test'
  48. else redirect = ''
  49.  
  50. if pos('NOEXIST',dboptn) ~= 0
  51. then exist = 1
  52. else exist = 0
  53.  
  54. link = 1
  55.  if pos('NOLINK',dboptn) ~= 0 then link = 0
  56.  
  57. comp = 1
  58. if pos('NOCOMP',dboptn) ~= 0
  59. then comp = 0
  60.  
  61. delobj = 0
  62. if pos('DELOBJ',dboptn) ~= 0
  63. then delobj = 1
  64.  
  65. work = 'ram:'
  66.  
  67. 'cd ram:'
  68. 'set "RXCOPTS=+ECH +L +BR "'
  69. parse value optn with name optn
  70. parse value name with path':'name .
  71. if name = '' 
  72. then do
  73.     name = path
  74.     path = ''
  75.     end
  76.  
  77. if path ~= '' then path = path':'
  78. cnt = lastpos('/',name)
  79. if cnt ~= 0
  80. then do
  81.     path = path||substr(name,1,cnt)
  82.     name = substr(name,cnt+1)
  83.     end
  84.  
  85. work = name
  86. do while work ~= ''
  87.     parse value work with name'/'work
  88.     if name ~= '' & work ~= ''
  89.     then
  90.         path = path||name'/'
  91.     end
  92.  
  93. if name = '*'
  94. then 
  95.     list = getlist()
  96. else
  97.         list = name
  98.  
  99. workpath = path
  100.  
  101. if open('errors',errors,'a')
  102. then do
  103.     call writeln('errors',list);
  104.     call close('errors')
  105.     end
  106.  
  107. parse value list with name list
  108. do while name ~= ''
  109.     
  110.     path = workpath
  111.     cnt = lastpos('/',name)
  112.     if cnt ~= 0
  113.     then do
  114.         path = path||substr(name,1,cnt)
  115.         name = substr(name,cnt+1)
  116.         end
  117.  
  118.     say substr(words(list),1,5)||name
  119.  
  120.     if exist & comp
  121.     then comp = ~exists(path||name)
  122.     else comp = 1
  123.  
  124.     if comp
  125.     then do
  126.         doval = dorexx()
  127.  
  128.         doval = exists('ram:'name'.obj')
  129.         if doval & link
  130.         then 
  131.                         'BLink ram:'name'.obj to RPDir:'name' lib lib:brexx.lib smallcode'
  132.  
  133.         if delobj
  134.         then
  135.             'delete ram:'name'.obj'
  136.         end
  137.  
  138.         parse value list with name list
  139.         end
  140. 'cd ram:'
  141.  
  142. HALT:
  143. BREAK_C:
  144.     exit
  145.  
  146. dorexx:
  147. options results
  148. SIGNAL ON BREAK_C
  149. SIGNAL ON SYNTAX
  150. SIGNAL ON ERROR
  151. SIGNAL ON FAILURE
  152. SIGNAL ON IOERR
  153.     if comp ~= 1 then return(0)
  154.     temp = 'cd:t'pragma('i')
  155.     'cd:rexxplus +fi'path||name '+fe'temp '+foram:'name'.obj +flram:'name'.lst' optn
  156.  
  157.     if open('errors',errors,'a')
  158.     then do
  159.         call writeln('errors',name rc)
  160.         call close('errors')
  161.         end
  162.     if exists(temp)
  163.     then do
  164.         'type' temp
  165.         'join 'errors temp 'as cd:t2'pragma('i')
  166.         'delete 'errors
  167.         'delete' temp
  168.         'rename cd:t2'pragma('i') errors
  169.         end
  170.     return(rc)
  171.  
  172. SYNTAX:
  173. IOERR:
  174. ERROR:
  175. FAILURE:
  176.     if open('errors',errors,'a')
  177.     then do
  178.         call writeln('errors',' 10')
  179.         call close('errors')
  180.         end
  181.     if exists(temp)
  182.     then do
  183.         'type' temp
  184.         'join 'temp errors'as cd:t2'pragma('i')
  185.         'delete 'errors
  186.         'delete' temp
  187.         'rename cd:t2'pragma('i') errors
  188.         end
  189.     return(10)
  190.  
  191. getlist: procedure expose path
  192.     parse arg extra
  193.  
  194.     list = ''
  195.     dir = showdir(path||extra,'D')
  196.     do while dir ~= ''
  197.         parse var dir curr dir
  198.             list = list getlist(extra||curr'/')
  199.         end
  200.  
  201.     list2 = showdir(path||extra,'F')
  202.     do while list2 ~= ''
  203.         parse var list2 file list2
  204.         list = list extra||file
  205.         end
  206.     return list
  207.